package com.amazon.jobtest.util;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {

	/**
	 * Returns an instance of date in the format informed by parameter,
	 * Returns null in case of being not possible convert the string to date
	 * @param date String the date in string format
	 * @param datePattern String the format that the date param has the date
	 * @return
	 */
	public static Date stringToDate(String date, String datePattern) {
		DateFormat formater = new SimpleDateFormat(datePattern);
		try {
			return formater.parse(date);
		} catch (ParseException e) {
			return null;
		}
		
	}
	

}
